/**
 * 表格肩部按钮click事件
 */

const tableShoulderBtnAction = window.presetVar.tableShoulderBtnAction;
const {body1} = window.presetVar.body;

/**
 * 增行、插行时，表体相关字段需根据表头设置其编辑性
 * @param {*} props 
 * @param {*} index 
 */
 export function AddRow(props){
    let rowIndex = props.cardTable.getVisibleRows(body1).length - 1;
    let bbhlFlag = props.form.getFormItemsValue(window.presetVar.head.head1,'org_currinfo')
    props.cardTable.setEditableByIndex(body1, rowIndex, ['org_currinfo'], !bbhlFlag)
}

function tableButtonClick() {
    return {
        [body1 + tableShoulderBtnAction.Add] : () => {
            this.props.cardTable.addRow(body1, undefined, null, false);
        },
        [body1 + '_Add']: {
            afterClick: (record, index) => {
                AddRow(this.props)
            }
        }
    }
}

export default tableButtonClick;